enum Device {
    case iPhone
    case iPad
    case macBook

    func description() -> String {
        switch self {
        case .iPhone:
            return "This is an iPhone"
        case .iPad:
            return "This is an iPad"
        case .macBook:
            return "This is a MacBook"
        }
    }
}
let device = Device.iPhone
print(device.description())  // 输出: This is an iPhone

// 定义计算属性
enum TrafficLight {
    case red
    case yellow
    case green

    var isSafeToGo: Bool {
        return self == .green
    }
}
let light = TrafficLight.green
print(light.isSafeToGo)  // 输出: true
